PHOENIX-7795 : Tenant TTL using Tenant Views on Multi-Tenant Table#2400
Open
palashc wants to merge 13 commits intoapache:masterfrom
Open
PHOENIX-7795 : Tenant TTL using Tenant Views on Multi-Tenant Table#2400palashc wants to merge 13 commits intoapache:masterfrom
palashc wants to merge 13 commits intoapache:masterfrom
Conversation
jpisaac
reviewed
Apr 21, 2026
Contributor
jpisaac
left a comment
There was a problem hiding this comment.
Looks good, Few test suggestions
added 2 commits
April 21, 2026 14:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable per-tenant TTL on multi-tenant base tables by letting a tenant create a view (with or without a
WHEREclause) and set TTL on it. Read masking and compaction use the existing View TTL infrastructure.Changes
WhereOptimizer.getRowKeyMatcher: computeROW_KEY_MATCHERfrom the connection's tenant-id when a tenant view is created without aWHEREclause, so it participates in the compactionRowKeyMatchertrie. WrapsScanUtil.getTenantIdBytesin try/catch to avoid breaking creation when the tenant-id type doesn't match the schema.CreateTableCompiler.compile: always invokegetRowKeyMatcherforUPDATABLEviews (no longer gated onwhere != null).New validation (
ViewUtil.validateTenantViewWithoutWhereTTLCoexistence)On a multi-tenant base table, among a given tenant's views without a WHERE clause, we allow either:
Multiple no-WHERE TTL views share the same
ROW_KEY_MATCHER(tenant-id bytes) and would conflict in the compactionRowKeyMatchertrie. The check rejects such operations withTENANT_VIEW_WITHOUT_WHERE_TTL_CONFLICT. Views withWHEREclauses are out of scope for this check (their prefix-conflict potential is a pre-existing concern tracked separately).The helper lives in
ViewUtiland is invoked from:CREATE VIEW(CreateTableCompiler) when creating a no-WHERE view on a multi-tenant base table.ALTER VIEW SET TTL(MetaDataClient.evaluateStmtProperties) when the view being altered is a no-WHERE tenant view on a multi-tenant base table; the view itself is excluded from the sibling check.Gracefully skips when
CHILD_LINKis unavailable (namespace mapping edge cases) or in connectionless mode (unit tests).Tests (
TenantTTLIT)testReadMaskingWithDifferentTenantTTLstestCompactionWithDifferentTenantTTLs— INTEGER non-tenant PKtestThreeTenantsDifferentTTLs—CHAR(3)+BIGINTPK columnstestCompactionWithSplitRegions— pre-split base tabletestCompactionWithSaltedMultiTenantTabletestCompactionWithTenantTableIndex— with secondary index on the base tabletestSameViewNameAcrossDifferentTenantstestTenantTTLWithUpdatableViewRestrictionEnabledtestTenantTTLViewCoexistenceRules— 9 cases exercising every CREATE-path branch (no-WHERE non-TTL, no-WHERE TTL, mixed, different tenants, newly-allowed WHERE-scoped creations)testAlterTTLOnTenantViewWithSiblingIsRejected— ALTER-path rejection for no-WHERE viewstestAlterTTLOnWhereScopedTenantViewIsAllowed— ALTER-path allowed for WHERE-scoped viewstestAlterTenantViewToAddTTL— ALTER TTL masking/compaction end-to-endtestChildViewsOfTenantTTLViewInheritTTL— child views inherit parent tenant view's TTL